package com.itheima.test02;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

public class Test09 {
    public static void main(String[] args) {
        ArrayList<String> poker0 = new ArrayList<>();
        String[] color = {"♠", "♥", "♣", "♦"};
        String[] numbers = {"2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3"};
        poker0.add("大王");
        poker0.add("小王");
        for (String number : numbers) {
            for (String s : color) {
                poker0.add(s + number);
            }
        }
        System.out.println(poker0);
        ArrayList<Integer> id = new ArrayList<>();
        for (int i = 0; i < 54; i++) {
            id.add(i);
        }
        //带序号的新牌盒
        HashMap<Integer, String> new_poker = new HashMap<>();
        for (int i = 0; i < poker0.size(); i++) {
            new_poker.put(i, poker0.get(i));
        }
        //洗牌(洗索引)
        Collections.shuffle(id);
        TreeSet<Integer> dipai_id = new TreeSet<>();
        TreeSet<Integer> player1_id = new TreeSet<>();
        TreeSet<Integer> player2_id = new TreeSet<>();
        TreeSet<Integer> player3_id = new TreeSet<>();
        for (int i = 0; i < id.size(); i++) {
            if (i >= id.size() - 3) {
                dipai_id.add(i);
            } else if (i % 3 == 0) {
                player1_id.add(i);
            } else if (i % 3 == 1) {
                player2_id.add(i);

            } else if (i % 3 == 2) {
                player3_id.add(i);
            }
        }

        look("张三丰手牌:",player1_id,new_poker);
        look("张无忌手牌:",player2_id,new_poker);
        look("张三手牌:",player3_id,new_poker);
        look("底牌:",dipai_id,new_poker);
    }
    //看牌
    public static void look(String name,TreeSet<Integer> id,HashMap<Integer,String> poker){
        ArrayList<String> pai = new ArrayList<>();
        for (Integer integer : id) {
            pai.add(poker.get(integer));
        }
        System.out.println(name+pai);
    }
}
